﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using SevenInvaders.common;

namespace SevenInvaders.LEVEL_AMANDA
{
    class AmandaPlayer:Player
    {
        SoundEffect somdotiro;

        public AmandaPlayer(Texture2D texture, Vector2 position, int player, GameWindow gameWindow, ContentManager Content)
            : base(texture, position, player, gameWindow, Content)
        {
            somdotiro = Content.Load<SoundEffect>("LEVEL_AMANDA/shootsound");
        }

        public void Update(GameTime gameTime, KeyboardState ks, KeyboardState ks_old)
        {
            #region Movimentação
            if (ks.IsKeyDown(Keys.Right))
            {
                this.PositionX += 3;
            }

            if (ks.IsKeyDown(Keys.Left))
            {
                this.PositionX -= 3;
            }

            if (ks.IsKeyDown(Keys.Up))
            {
                this.PositionY -= 3;
            }

            if (ks.IsKeyDown(Keys.Down))
            {
                this.PositionY += 3;
            }
            #endregion

            if (ks.IsKeyDown(Keys.Space) && !ks_old.IsKeyDown(Keys.Space))
            {
                Shoot.list.Add(new Shoot(Game1.amandatiro, new Vector2 (this.Position.X + this.current_animation.frame.Width / 2 - 3, this.Position.Y), Shoot.Direction.UP, this.Velocity
                    + new Vector2(0, 5)));

                somdotiro.Play();
                
            }

            #region Colisao borda da tela
            if (this.PositionX + this.Texture.Bounds.Width > Window.ClientBounds.Width)
            {
                this.PositionX = Window.ClientBounds.Width - this.Texture.Bounds.Width;
            }

            if (this.PositionX <= 0)
            {
                this.PositionX = 0;
            }

            if (this.PositionY + this.Texture.Bounds.Height > Window.ClientBounds.Height)
            {
                this.PositionY = Window.ClientBounds.Height - this.Texture.Bounds.Height;
            }

            if (this.PositionY <= 0)
            {
                this.PositionY = 0;
            }
            #endregion

        }
    }
}
